﻿using System.Drawing;

namespace TodoSoft.Controls
{
	public class TreeGridHeaderRow
	{
		private readonly TreeGridGroup _group;
		
		public TreeGridHeaderRow(TreeGridGroup group)
		{
			TextColor = Color.Black;
			BorderColor = Color.Black;
			_group = group;
		}

		public bool Visible = true;
		public int Top = 0;
		public int Height = 18;
		public int Width = 0;
		public int Bottom
		{
			get { return Top + Height; }
		}

		public Color BackgroundColor = Color.Transparent;
		public Font Font = new Font("Tahoma", 10, FontStyle.Bold);

		public Color TextColor
		{
			set
			{
				_textColor = value;
				TextBrush = new SolidBrush(_textColor);
			}
			get
			{
				return _textColor;
			}
		}

		public Color BorderColor
		{
			set
			{
				_borderColor = value;
				BorderPen = new Pen(_borderColor, 1);
			}
			get
			{
				return _borderColor;
			}
		}

		public Brush TextBrush;
		public Pen BorderPen;
		private Color _textColor;
		private Color _borderColor;

		internal void Paint(Graphics graphics)
		{
			foreach (var column in _group.Columns)
			{
				column.Paint(graphics);

				graphics.DrawLine(
					_group.HeaderRow.BorderPen,
					0,
					Bottom - 1,
					Width,
					Bottom - 1);
			}
		}
	}
}